package com.andatsoft.laisim.widget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;

import com.andatsoft.laisim.service.PlayerService;

public class WidgetProvider extends AppWidgetProvider {

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		if (PlayerService.isServiceStartedByMainActivity) {
			Intent in = new Intent(context.getApplicationContext(),
					PlayerService.class);
			in.putExtra(PlayerService.INTENT_SERVICE_COMMAND,
					PlayerService.SERVICE_COMMAND_BASE_WIDGET_UPDATE);
			context.getApplicationContext().startService(in);
		} else {
			Intent in = new Intent(context.getApplicationContext(),
					PlayerService.class);
			in.putExtra(PlayerService.INTENT_SERVICE_COMMAND,
					PlayerService.SERVICE_COMMAND_MAIN_ACTIVITY);
			in.putExtra(PlayerService.INTENT_SERVICE_COMMAND_EXTRAS, 1);
			context.getApplicationContext().startService(in);
		}
	}
}
